package com.glc.gao.gavin.rxjavademo.operator;

import android.util.Log;
import android.view.View;

import com.glc.gao.gavin.rxjavademo.R;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

public class DoOnNextActivity extends BaseActivity {
    @Override
    public int getDescribeText() {
        return R.string.describe_doOnNext;
    }

    @Override
    protected int getContextView() {
        return R.layout.activity_do_on_next;
    }

    public void executeDoOnNext(View view) {

        Observable.just(1, 2, 3, 4)
                .doOnNext(new Consumer<Integer>() {
                    @Override
                    public void accept(@NonNull Integer integer) throws Exception {
                        print("doOnNext 保存 " + integer + "成功" + "\n");
                    }
                }).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(@NonNull Integer integer) throws Exception {
                print("doOnNext :" + integer + "\n");
            }
        });
    }
}
